/* 引入字体设置基础 */
:root {
    --main-color: #1890ff;
    --main-color-dark: #096dd9;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --error-color: #f5222d;
    --text-color: #333;
    --text-color-secondary: #888;
    --border-color: #e8e8e8;
    --border-radius: 15px;
    --bubble-radius: 30px;
    --header-height: 120px;
    --input-height: 90px;
  }
  
  /* 主容器样式 */
  .container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f0f2f5;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  }
  
  /* 聊天窗口容器 */
  .chatContainer {
    width: 100%;
    max-width: 900px;
    height: 90vh;
    max-height: 1300px;
    background-color: #fff;
    border-radius: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
  }
  
  /* 头部区域 */
  .header {
    background: linear-gradient(135deg, var(--main-color), var(--main-color-dark));
    color: #fff;
    padding: 30px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    height: var(--header-height);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  }
  
  .backButton {
    position: absolute;
    left: 20px;
    top: 30px;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 40px;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 10px;
    z-index: 10;
    min-width: 50px;
    min-height: 50px;
  }
  
  .backButton:hover {
    opacity: 0.8;
  }
  
  .headerTitle {
    display: flex;
    align-items: center;
    flex-direction: column;
    align-items: flex-start;
    margin-left: 60px;
  }
  
  .logo {
    font-size: 42px;
    font-weight: bold;
    margin-bottom: 10px;
  }
  
  .status {
    display: flex;
    align-items: center;
    font-size: 28px;
    flex-wrap: wrap;
  }
  
  .statusIndicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 8px;
    display: inline-block;
  }
  
  .statusText {
    opacity: 0.85;
    margin-right: 20px;
  }
  
  .userRole {
    opacity: 0.85;
    margin-right: 20px;
    font-weight: 500;
  }
  
  .userId {
    opacity: 0.7;
    font-size: 24px;
    display: inline-block;
  }
  
  .headerActions {
    display: flex;
    align-items: center;
  }
  
  .settingsIcon {
    font-size: 48px;
    cursor: pointer;
    transition: all 0.3s;
    padding: 12px;
  }
  
  .settingsIcon:hover {
    transform: rotate(45deg);
  }
  
  /* 设置面板 */
  .settingsPanel {
    position: absolute;
    top: 120px;
    right: 0;
    width: 450px;
    background-color: #fff;
    border-radius: 0 0 15px 15px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
    z-index: 10;
    color: var(--text-color);
    animation: slideDown 0.3s ease;
  }
  
  @keyframes slideDown {
    from {
      opacity: 0;
      transform: translateY(-20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .settingsHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 500;
    font-size: 32px;
  }
  
  .settingsHeader svg {
    cursor: pointer;
    opacity: 0.6;
    font-size: 32px;
  }
  
  .settingsHeader svg:hover {
    opacity: 1;
  }
  
  .settingsContent {
    padding: 24px 32px;
  }
  
  .settingItem {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    font-size: 28px;
  }
  
  .idValue {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .roleToggleButton {
    width: 100%;
    padding: 20px 0;
    background-color: var(--main-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-top: 16px;
    font-size: 28px;
    font-weight: 500;
  }
  
  .roleToggleButton:hover:not(:disabled) {
    background-color: var(--main-color-dark);
  }
  
  .roleToggleButton:disabled {
    background-color: #bfbfbf;
    cursor: not-allowed;
  }
  
  /* 聊天区域 */
  .chatArea {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background-color: #f7f9fb;
    height: calc(100% - var(--header-height) - var(--input-height));
    position: relative;
  }
  
  /* 错误提示 */
  .errorNotice {
    background-color: #fff2f0;
    border: 1px solid #ffccc7;
    border-radius: 8px;
    padding: 16px 24px;
    margin-bottom: 30px;
    color: var(--error-color);
    font-size: 28px;
    text-align: center;
  }
  
  .errorMessage {
    color: var(--error-color);
    font-size: 24px;
    margin-top: 16px;
  }
  
  /* 欢迎消息 */
  .welcomeMessage {
    text-align: center;
    color: #8c8c8c;
    margin-top: 80px;
    padding: 0 30px;
  }
  
  .welcomeIcon {
    font-size: 96px;
    margin-bottom: 40px;
  }
  
  .welcomeIcon svg {
    font-size: inherit;
  }
  
  .welcomeMessage p {
    font-size: 32px;
    line-height: 1.5;
  }
  
  .connectingMessage {
    margin-top: 30px;
    color: var(--text-color-secondary);
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .loadingIcon {
    margin-right: 10px;
    color: var(--warning-color);
  }
  
  /* 消息样式 */
  .messageWrapper {
    margin-bottom: 40px;
    max-width: 70%;
    animation: fadeIn 0.3s ease;
  }
  
  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .myMessage {
    margin-left: auto;
    text-align: right;
  }
  
  .otherMessage {
    margin-right: auto;
    text-align: left;
  }
  
  /* 本地消息样式（等待确认） */
  .localMessage .messageBubble {
    opacity: 0.7;
  }
  
  .localMessage .messageBubble::after {
    content: ' ';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 8px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.7);
    animation: pulse 1.5s infinite;
  }
  
  @keyframes pulse {
    0% {
      transform: scale(0.8);
      opacity: 0.8;
    }
    50% {
      transform: scale(1.2);
      opacity: 1;
    }
    100% {
      transform: scale(0.8);
      opacity: 0.8;
    }
  }
  
  .messageInfo {
    margin-bottom: 10px;
    display: flex;
    font-size: 24px;
    color: var(--text-color-secondary);
  }
  
  .messageUser {
    flex: 1;
    display: flex;
    align-items: center;
  }
  
  .messageUserId {
    font-size: 20px;
    opacity: 0.7;
    margin-left: 5px;
    font-weight: normal;
  }
  
  .messageTime {
    margin-left: 20px;
    min-width: 50px;
    text-align: right;
  }
  
  .myMessage .messageInfo {
    flex-direction: row-reverse;
  }
  
  .myMessage .messageTime {
    margin-left: 0;
    margin-right: 20px;
  }
  
  .messageBubble {
    padding: 24px 30px;
    border-radius: var(--bubble-radius);
    display: inline-block;
    max-width: 100%;
    word-break: break-word;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    line-height: 1.5;
    font-size: 28px;
  }
  
  .myMessage .messageBubble {
    background-color: var(--main-color);
    color: white;
    border-top-right-radius: 8px;
  }
  
  .otherMessage .messageBubble {
    background-color: white;
    color: var(--text-color);
    border-top-left-radius: 8px;
    border: 1px solid var(--border-color);
  }
  
  /* 输入区域 */
  .inputArea {
    padding: 20px 30px;
    background-color: #fff;
    border-top: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    height: var(--input-height);
  }
  
  .messageInput {
    flex: 1;
    border: 1px solid #d9d9d9;
    border-radius: 45px;
    padding: 20px 30px;
    outline: none;
    transition: all 0.3s;
    font-size: 28px;
    height: 90px;
  }
  
  .messageInput:focus {
    border-color: var(--main-color);
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
  }
  
  .messageInput:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
  }
  
  .sendButton {
    margin-left: 20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    background-color: var(--main-color);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 36px;
  }
  
  .sendButton:hover:not(:disabled) {
    background-color: var(--main-color-dark);
    transform: scale(1.05);
  }
  
  .sendButton:disabled {
    background-color: #d9d9d9;
    cursor: not-allowed;
  }
  
  .sendButton svg {
    font-size: inherit;
  }
  
  /* 滚动条样式 */
  .chatArea::-webkit-scrollbar {
    width: 15px;
  }
  
  .chatArea::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 15px;
  }
  
  .chatArea::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
  }
  
  .chatArea::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
  }
  
  /* 适配不同屏幕尺寸 - 移动优先设计 */
  @media screen and (max-width: 750px) {
    .container {
      padding: 0;
    }
    
    .chatContainer {
      width: 100%;
      height: 100vh;
      max-height: 100vh;
      border-radius: 0;
    }
    
    .header {
      padding: 20px 15px;
      height: auto;
    }
    
    .backButton {
      left: 10px;
      top: 15px;
      font-size: 30px;
      min-width: 40px;
      min-height: 40px;
    }
    
    .logo {
      font-size: 32px;
      margin-left: 50px;
    }
    
    .status {
      font-size: 24px;
    }
    
    .userRole, .userId {
      font-size: 20px;
      margin-right: 10px;
    }
    
    .statusIndicator {
      width: 10px;
      height: 10px;
    }
    
    .settingsIcon {
      font-size: 36px;
      padding: 8px;
    }
    
    .settingsPanel {
      width: 90%;
      right: 5%;
      left: 5%;
      top: 110px;
    }
    
    .settingsHeader {
      padding: 16px;
      font-size: 24px;
    }
    
    .settingsContent {
      padding: 16px;
    }
    
    .settingItem {
      font-size: 22px;
      margin-bottom: 16px;
    }
    
    .chatArea {
      padding: 15px;
    }
    
    .welcomeIcon {
      font-size: 72px;
      margin-bottom: 20px;
    }
    
    .welcomeMessage p {
      font-size: 26px;
    }
    
    .messageWrapper {
      max-width: 85%;
    }
    
    .messageBubble {
      padding: 16px 20px;
      font-size: 24px;
    }
    
    .messageInfo {
      font-size: 20px;
    }
    
    .messageUserId {
      font-size: 16px;
    }
    
    .inputArea {
      padding: 15px;
      height: auto;
      min-height: 70px;
    }
    
    .messageInput {
      padding: 12px 20px;
      font-size: 24px;
      height: 70px;
    }
    
    .sendButton {
      width: 60px;
      height: 60px;
      font-size: 28px;
    }
    
    .errorNotice {
      font-size: 22px;
      padding: 10px 15px;
    }
  }
  
  /* 超小屏幕适配 */
  @media screen and (max-width: 400px) {
    .header {
      padding: 15px 10px;
      flex-direction: column;
      align-items: flex-start;
    }

    .backButton {
      left: 5px;
      top: 10px;
      font-size: 20px;
      min-width: 30px;
      min-height: 30px;
    }

    .logo {
      font-size: 28px;
      margin-left: 40px;
    }
    
    .status {
      font-size: 18px;
    }
    
    .userRole, .userId {
      font-size: 16px;
      margin-right: 6px;
    }
    
    .settingsIcon {
      font-size: 30px;
      padding: 5px;
    }
    
    .settingsHeader {
      padding: 12px;
      font-size: 20px;
    }
    
    .settingsContent {
      padding: 12px;
    }
    
    .settingItem {
      font-size: 18px;
      margin-bottom: 12px;
    }
    
    .roleToggleButton {
      padding: 12px 0;
      font-size: 20px;
    }
    
    .messageWrapper {
      max-width: 90%;
    }
    
    .messageInfo {
      font-size: 16px;
    }
    
    .messageUserId {
      font-size: 14px;
    }
    
    .messageBubble {
      padding: 12px 16px;
      font-size: 20px;
    }
    
    .inputArea {
      padding: 10px;
      min-height: 60px;
    }
    
    .messageInput {
      padding: 10px 15px;
      font-size: 20px;
      height: 55px;
    }
    
    .sendButton {
      width: 48px;
      height: 48px;
      font-size: 22px;
      margin-left: 10px;
    }
    
    .welcomeMessage {
      margin-top: 40px;
    }
    
    .welcomeIcon {
      font-size: 60px;
      margin-bottom: 15px;
    }
    
    .welcomeMessage p {
      font-size: 20px;
    }
    
    .connectingMessage {
      font-size: 18px;
    }
  }
  
  /* 暗黑模式支持 */
  @media (prefers-color-scheme: dark) {
    :root {
      --main-color: #177ddc;
      --main-color-dark: #0958d9;
      --text-color: #f0f0f0;
      --text-color-secondary: #aaaaaa;
      --border-color: #434343;
    }
    
    .container {
      background-color: #121212;
    }
    
    .chatContainer {
      background-color: #1f1f1f;
    }
    
    .chatArea {
      background-color: #1f1f1f;
    }
    
    .otherMessage .messageBubble {
      background-color: #303030;
      color: var(--text-color);
      border-color: #303030;
    }
    
    .welcomeMessage {
      color: #bbbbbb;
    }
    
    .inputArea, .settingsPanel {
      background-color: #1f1f1f;
      border-color: #303030;
    }
    
    .messageInput {
      background-color: #303030;
      color: var(--text-color);
      border-color: #444444;
    }
    
    .settingsHeader {
      border-color: #303030;
    }
    
    .settingsContent {
      color: var(--text-color);
    }
    
    .errorNotice {
      background-color: rgba(255, 77, 79, 0.2);
      border-color: #ff4d4f;
      color: #ff7875;
    }
  }
  
  /* 为所有交互元素添加触觉反馈 */
  .sendButton, 
  .roleToggleButton, 
  .settingsIcon {
    position: relative;
    overflow: hidden;
  }
  
  .sendButton::after,
  .roleToggleButton::after,
  .settingsIcon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    opacity: 0;
    border-radius: inherit;
    transform: translate(-50%, -50%) scale(0);
    transition: opacity 0.3s, transform 0.3s;
  }
  
  .sendButton:active::after,
  .roleToggleButton:active::after,
  .settingsIcon:active::after {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  
  .reconnectButton {
    margin-top: 16px;
    padding: 12px 25px;
    background-color: var(--main-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 24px;
    font-weight: 500;
    display: block;
    margin-left: auto;
    margin-right: auto;
  }
  
  .reconnectButton:hover {
    background-color: var(--main-color-dark);
  }
  
  /* 新增高级设置样式 */
  .advancedSettingsToggle {
    margin-top: 24px;
    text-align: center;
    color: var(--text-color-secondary);
    cursor: pointer;
    font-size: 24px;
    transition: color 0.3s;
  }
  
  .advancedSettingsToggle:hover {
    color: var(--main-color);
  }
  
  .advancedSettings {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed #e8e8e8;
  }
  
  .portInput {
    padding: 10px 15px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    width: 120px;
    font-size: 24px;
    text-align: center;
  }
  
  .portInput:focus {
    border-color: var(--main-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
  }